package main

import (
	"MyDemo/MyZinx/ziface"
	"MyDemo/MyZinx/znet"
	"fmt"
)

/*
	基于Zinx框架开发的 服务端应用程序
*/

// ping test 自定义路由
type PingRouter struct {
	znet.BaseRouter
}

func (this *PingRouter) Handle(request ziface.IRequest) {
	fmt.Println("Call Router Handle...")
	fmt.Println("recv from client: msgId=", request.GetMsgId(), " data=", string(request.GetData()))
	err := request.GetConnection().SendMsg(1, []byte("ping...ping..,ping..."))
	if err != nil {
		fmt.Println(err)
	}
}

func main() {
	s := znet.NewServer("[zinx V0.5]")
	s.AddRouter(&PingRouter{})
	s.Serve()
}
